{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "88abb256-50a7-43ee-8bc7-8178a0469c2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "convert_dict = {\n",
    "    # 这个是Vis的类别转到整个的类别的字典\n",
    "    0: 26,#pedestrian\n",
    "    1: 4,#people\n",
    "    2: 9,#bicycle\n",
    "    3: 0,#car\n",
    "    4: 1,#van\n",
    "    5: 2,#truck\n",
    "    6: 27,#tricycle --三轮车\n",
    "    7: 28,#awning-tricycle -- 带遮阳棚的三轮车\n",
    "    8: 13,#bus\n",
    "    9: 20,#motor\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fd7388c6-6611-48ab-8c6c-947b8775fb14",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/root/autodl-tmp/yolo_incremental_learning/utils/general.py:32: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.\n",
      "  import pkg_resources as pkg\n"
     ]
    }
   ],
   "source": [
    "from utils.general import download, os, Path\n",
    "\n",
    "def visdrone2yolo(dir):\n",
    "  from PIL import Image\n",
    "  from tqdm import tqdm\n",
    "\n",
    "  def convert_box(size, box):\n",
    "      # Convert VisDrone box to YOLO xywh box\n",
    "      dw = 1. / size[0]\n",
    "      dh = 1. / size[1]\n",
    "      return (box[0] + box[2] / 2) * dw, (box[1] + box[3] / 2) * dh, box[2] * dw, box[3] * dh\n",
    "\n",
    "  (dir / 'labels').mkdir(parents=True, exist_ok=True)  # make labels directory\n",
    "  pbar = tqdm((dir / 'annotations').glob('*.txt'), desc=f'Converting {dir}')\n",
    "  for f in pbar:\n",
    "      img_size = Image.open((dir / 'images' / f.name).with_suffix('.jpg')).size\n",
    "      lines = []\n",
    "      with open(f, 'r') as file:  # read annotation.txt\n",
    "          for row in [x.split(',') for x in file.read().strip().splitlines()]:\n",
    "              if row[4] == '0':  # VisDrone 'ignored regions' class 0\n",
    "                  continue\n",
    "              cls = convert_dict[int(row[5]) - 1]\n",
    "              box = convert_box(img_size, tuple(map(int, row[:4])))\n",
    "              lines.append(f\"{cls} {' '.join(f'{x:.6f}' for x in box)}\\n\")\n",
    "              with open(str(f).replace(os.sep + 'annotations' + os.sep, os.sep + 'labels' + os.sep), 'w') as fl:\n",
    "                  fl.writelines(lines)  # write label.txt\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f005135-ac77-4653-894d-eaa6b5b59dca",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e8879195-07f9-41c1-a7c3-5314c6de7ea1",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Converting /root/autodl-tmp/VisDrone/VisDrone2019-DET-train: 0it [00:00, ?it/s]\n",
      "Converting /root/autodl-tmp/VisDrone/VisDrone2019-DET-val: 0it [00:00, ?it/s]\n",
      "Converting /root/autodl-tmp/VisDrone/VisDrone2019-DET-test-dev: 0it [00:00, ?it/s]\n"
     ]
    }
   ],
   "source": [
    "dir = Path('/root/autodl-tmp/VisDrone')  # dataset root dir\n",
    "\n",
    "# Convert\n",
    "for d in 'VisDrone2019-DET-train', 'VisDrone2019-DET-val', 'VisDrone2019-DET-test-dev':\n",
    "  visdrone2yolo(dir / d)  # convert VisDrone annotations to YOLO labels\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0f3f4f06-1ec6-4858-ba60-bb479fb837d0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6179a131-86f5-42ef-ada2-c147c767ef0a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "237cfeea-d63e-4121-80ee-9a936f61c2b4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4bad953a-27b3-4a9f-9f42-1b6174d13435",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[34m\u001b[1mtrain_Lwf: \u001b[0mweights=./runs/train/increment_VOC_plain/weights/best.pt, cfg=models/yolov5s_VisVOCKITTI.yaml, data=data/VisDrone_incremental.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=10, batch_size=16, imgsz=640, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, evolve_population=data/hyps, resume_evolve=None, bucket=, cache=None, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=1, artifact_alias=latest, ndjson_console=False, ndjson_file=False, ewc_pt=None, ewc_lambda=0.0, SI_enable=False, SI_pt=None, SI_lambda=10.0, Lwf_enable=False, Lwf_lambda=0.0001, Lwf_temperature=1.0\n",
      "\u001b[34m\u001b[1mgithub: \u001b[0m⚠️ YOLOv5 is out of date by 2895 commits. Use 'git pull ultralytics master' or 'git clone https://github.com/ultralytics/yolov5' to update.\n",
      "YOLOv5 🚀 a471430d Python-3.10.8 torch-2.1.2+cu118 CUDA:0 (NVIDIA GeForce RTX 3090, 24135MiB)\n",
      "\n",
      "\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0\n",
      "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Experiment is live on comet.com \u001b[38;5;39mhttps://www.comet.com/nagasaki-soyorin/yolov5/eb4cdc7ef9174234ae189fce5bf9f820\u001b[0m\n",
      "\n",
      "\n",
      "                 from  n    params  module                                  arguments                     \n",
      "  0                -1  1      3520  models.common.Conv                      [3, 32, 6, 2, 2]              \n",
      "  1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]                \n",
      "  2                -1  1     18816  models.common.C3                        [64, 64, 1]                   \n",
      "  3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               \n",
      "  4                -1  2    115712  models.common.C3                        [128, 128, 2]                 \n",
      "  5                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]              \n",
      "  6                -1  3    625152  models.common.C3                        [256, 256, 3]                 \n",
      "  7                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]              \n",
      "  8                -1  1   1182720  models.common.C3                        [512, 512, 1]                 \n",
      "  9                -1  1    656896  models.common.SPPF                      [512, 512, 5]                 \n",
      " 10                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              \n",
      " 11                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          \n",
      " 12           [-1, 6]  1         0  models.common.Concat                    [1]                           \n",
      " 13                -1  1    361984  models.common.C3                        [512, 256, 1, False]          \n",
      " 14                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              \n",
      " 15                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          \n",
      " 16           [-1, 4]  1         0  models.common.Concat                    [1]                           \n",
      " 17                -1  1     90880  models.common.C3                        [256, 128, 1, False]          \n",
      " 18                -1  1    147712  models.common.Conv                      [128, 128, 3, 2]              \n",
      " 19          [-1, 14]  1         0  models.common.Concat                    [1]                           \n",
      " 20                -1  1    296448  models.common.C3                        [256, 256, 1, False]          \n",
      " 21                -1  1    590336  models.common.Conv                      [256, 256, 3, 2]              \n",
      " 22          [-1, 10]  1         0  models.common.Concat                    [1]                           \n",
      " 23                -1  1   1182720  models.common.C3                        [512, 512, 1, False]          \n",
      " 24      [17, 20, 23]  1     91704  models.yolo.Detect                      [29, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]]\n",
      "YOLOv5s_VisVOCKITTI summary: 217 layers, 7097848 parameters, 7097848 gradients, 16.2 GFLOPs\n",
      "\n",
      "Transferred 342/355 items from runs/train/increment_VOC_plain/weights/best.pt\n",
      "\u001b[34m\u001b[1mAMP: \u001b[0mchecks passed ✅\n",
      "\u001b[34m\u001b[1moptimizer:\u001b[0m SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 66 weight(decay=0.0005), 60 bias\n",
      "\u001b[34m\u001b[1malbumentations: \u001b[0m1 validation error for InitSchema\n",
      "size\n",
      "  Field required [type=missing, input_value={'height': 640, 'width': ...'mask_interpolation': 0}, input_type=dict]\n",
      "    For further information visit https://errors.pydantic.dev/2.10/v/missing\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mScanning /root/autodl-tmp/datasets/VisDrone/VisDrone2019-DET-train/labels\u001b[0m\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mWARNING ⚠️ /root/autodl-tmp/datasets/VisDrone/VisDrone2019-DET-train/images/0000137_02220_d_0000163.jpg: 1 duplicate labels removed\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mWARNING ⚠️ /root/autodl-tmp/datasets/VisDrone/VisDrone2019-DET-train/images/0000140_00118_d_0000002.jpg: 1 duplicate labels removed\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mWARNING ⚠️ /root/autodl-tmp/datasets/VisDrone/VisDrone2019-DET-train/images/9999945_00000_d_0000114.jpg: 1 duplicate labels removed\n",
      "\u001b[34m\u001b[1mtrain: \u001b[0mWARNING ⚠️ /root/autodl-tmp/datasets/VisDrone/VisDrone2019-DET-train/images/9999987_00000_d_0000049.jpg: 1 duplicate labels removed\n",
      "\u001b[34m\u001b[1mval: \u001b[0mScanning /root/autodl-tmp/datasets/VisDrone/VisDrone2019-DET-val/labels.cac\u001b[0m\n",
      "\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0m2.95 anchors/target, 0.933 Best Possible Recall (BPR). Anchors are a poor fit to dataset ⚠️, attempting to improve...\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0mWARNING ⚠️ Extremely small objects found: 29644 of 343201 labels are <3 pixels in size\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0mRunning kmeans for 9 anchors on 342304 points...\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0mEvolving anchors with Genetic Algorithm: fitness = 0.7493: 100%|████\u001b[0m\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0mthr=0.25: 0.9995 best possible recall, 5.74 anchors past thr\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0mn=9, img_size=640, metric_all=0.364/0.748-mean/best, past_thr=0.485-mean: 3,5, 4,9, 8,7, 8,15, 16,9, 16,21, 33,17, 29,37, 61,63\n",
      "\u001b[34m\u001b[1mAutoAnchor: \u001b[0mDone ✅ (optional: update model *.yaml to use these anchors in the future)\n",
      "Plotting labels to runs/train/exp158/labels.jpg... \n",
      "Image sizes 640 train, 640 val\n",
      "Using 8 dataloader workers\n",
      "Logging results to \u001b[1mruns/train/exp158\u001b[0m\n",
      "Starting training for 10 epochs...\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        0/9      3.64G     0.1343     0.1344    0.06474        431        640: 1\n",
      "tensor([2.14821], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.137      0.108     0.0441     0.0176\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        1/9      3.84G     0.1151     0.1652    0.04512        589        640: 1\n",
      "tensor([2.43685], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.276      0.149     0.0834     0.0348\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        2/9      3.84G     0.1103     0.1721    0.03954        586        640: 1\n",
      "tensor([2.45826], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.292      0.179      0.105     0.0451\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        3/9      3.84G     0.1066     0.1708    0.03708        785        640: 1\n",
      "tensor([2.30100], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.445      0.194      0.133     0.0596\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        4/9      3.84G     0.1044     0.1712    0.03517        417        640: 1\n",
      "tensor([2.09115], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.389      0.206      0.154     0.0712\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        5/9      3.84G     0.1027     0.1694    0.03369        276        640: 1\n",
      "tensor([1.65927], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.397      0.205      0.165      0.076\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        6/9      3.84G     0.1018     0.1682    0.03274        436        640: 1\n",
      "tensor([2.02407], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.391      0.216      0.176     0.0844\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        7/9      3.84G     0.1012     0.1679    0.03223        521        640: 1\n",
      "tensor([2.12058], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.423      0.208      0.183     0.0891\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        8/9      3.84G     0.1003     0.1677    0.03178        326        640: 1\n",
      "tensor([1.69781], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759       0.37      0.223      0.194     0.0955\n",
      "\n",
      "      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size\n",
      "        9/9      3.84G    0.09993     0.1665    0.03149        498        640: 1\n",
      "tensor([2.00628], device='cuda:0', grad_fn=<MulBackward0>)  \n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.361       0.22      0.197     0.0978\n",
      "\n",
      "10 epochs completed in 0.151 hours.\n",
      "Optimizer stripped from runs/train/exp158/weights/last.pt, 14.5MB\n",
      "Optimizer stripped from runs/train/exp158/weights/best.pt, 14.5MB\n",
      "\n",
      "Validating runs/train/exp158/weights/best.pt...\n",
      "Fusing layers... \n",
      "YOLOv5s_VisVOCKITTI summary: 160 layers, 7088344 parameters, 0 gradients, 16.0 GFLOPs\n",
      "                 Class     Images  Instances          P          R      mAP50   WARNING ⚠️ NMS time limit 2.100s exceeded\n",
      "                 Class     Images  Instances          P          R      mAP50   WARNING ⚠️ NMS time limit 2.100s exceeded\n",
      "                 Class     Images  Instances          P          R      mAP50   \n",
      "                   all        548      38759      0.357      0.209      0.186     0.0937\n",
      "                   car        548      14064       0.46      0.672      0.633      0.387\n",
      "                   van        548       1975      0.265      0.162      0.134     0.0866\n",
      "                 truck        548        750      0.305      0.169      0.143     0.0835\n",
      "                person        548       5125      0.321       0.23       0.19     0.0601\n",
      "               bicycle        548       1287          0          0     0.0205    0.00624\n",
      "                   bus        548        251      0.321      0.227      0.135     0.0763\n",
      "             motorbike        548       4886      0.351      0.276      0.222     0.0725\n",
      "            pedestrian        548       8844      0.302      0.355      0.295      0.113\n",
      "              tricycle        548       1045      0.248    0.00287     0.0551     0.0314\n",
      "       awning-tricycle        548        532          1          0     0.0366     0.0218\n",
      "Results saved to \u001b[1mruns/train/exp158\u001b[0m\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m ---------------------------------------------------------------------------------------\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m Comet.ml Experiment Summary\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m ---------------------------------------------------------------------------------------\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m   Data:\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     display_summary_level : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     name                  : exp\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     url                   : \u001b[38;5;39mhttps://www.comet.com/nagasaki-soyorin/yolov5/eb4cdc7ef9174234ae189fce5bf9f820\u001b[0m\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m   Metrics [count] (min, max):\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_f1              : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_false_positives : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_mAP@.5          : 0.03655870512317689\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_mAP@.5:.95      : 0.021804419071261943\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_precision       : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_recall          : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_support         : 532\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     awning-tricycle_true_positives  : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_f1                      : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_false_positives         : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_mAP@.5                  : 0.020481703971520555\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_mAP@.5:.95              : 0.006239831686438392\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_precision               : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_recall                  : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_support                 : 1287\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bicycle_true_positives          : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_f1                          : 0.26586238052593736\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_false_positives             : 121.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_mAP@.5                      : 0.13545891650719782\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_mAP@.5:.95                  : 0.07626498735319488\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_precision                   : 0.32059705868504196\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_recall                      : 0.22709163346613545\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_support                     : 251\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bus_true_positives              : 57.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_f1                          : 0.5458121272427654\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_false_positives             : 11108.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_mAP@.5                      : 0.6330359437600424\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_mAP@.5:.95                  : 0.3865803891570141\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_precision                   : 0.4596231437557816\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_recall                      : 0.6717861205915814\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_support                     : 14064\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     car_true_positives              : 9448.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     loss [401]                      : (3.9010698795318604, 6.247920513153076)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     metrics/mAP_0.5 [20]            : (0.04405893193160586, 0.19692295976588844)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     metrics/mAP_0.5:0.95 [20]       : (0.017604415082169155, 0.09782379425766068)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     metrics/precision [20]          : (0.13652726456897013, 0.445472730944501)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     metrics/recall [20]             : (0.10780624877227458, 0.22258427384305093)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_f1                    : 0.3088565663961623\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_false_positives       : 2495.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_mAP@.5                : 0.22247509594990533\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_mAP@.5:.95            : 0.07253699813120627\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_precision             : 0.350770279753837\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_recall                : 0.2758902988129349\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_support               : 4886\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     motorbike_true_positives        : 1348.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_f1                   : 0.3265819819903489\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_false_positives      : 7266.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_mAP@.5               : 0.29459358810069974\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_mAP@.5:.95           : 0.1125020444131847\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_precision            : 0.30201813334399497\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_recall               : 0.35549525101763907\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_support              : 8844\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     pedestrian_true_positives       : 3144.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_f1                       : 0.2680327397943213\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_false_positives          : 2487.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_mAP@.5                   : 0.18990552210941014\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_mAP@.5:.95               : 0.060097542913383505\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_precision                : 0.32142137326684295\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_recall                   : 0.22985365853658538\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_support                  : 5125\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     person_true_positives           : 1178.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     train/box_loss [20]             : (0.0999288409948349, 0.1342509686946869)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     train/cls_loss [20]             : (0.03148603066802025, 0.06473883986473083)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     train/obj_loss [20]             : (0.13444660604000092, 0.1720903217792511)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_f1                     : 0.0056758263277059675\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_false_positives        : 9.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_mAP@.5                 : 0.05511585908652688\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_mAP@.5:.95             : 0.03141482493691296\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_precision              : 0.24763104450604453\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_recall                 : 0.0028708133971291866\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_support                : 1045\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     tricycle_true_positives         : 3.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_f1                        : 0.21762991660234637\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_false_positives           : 290.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_mAP@.5                    : 0.14264076328532227\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_mAP@.5:.95                : 0.08346855567191605\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_precision                 : 0.30453209042837337\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_recall                    : 0.16931398064731396\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_support                   : 750\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     truck_true_positives            : 127.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     val/box_loss [20]               : (0.09620919823646545, 0.11444727331399918)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     val/cls_loss [20]               : (0.034121427685022354, 0.05341525375843048)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     val/obj_loss [20]               : (0.2260809987783432, 0.2379540354013443)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_f1                          : 0.20063076377768427\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_false_positives             : 886.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_mAP@.5                      : 0.13372141275078933\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_mAP@.5:.95                  : 0.08655258721481955\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_precision                   : 0.2647366732332476\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_recall                      : 0.16151898734177214\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_support                     : 1975\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     van_true_positives              : 319.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     x/lr0 [20]                      : (0.00208, 0.07007407407407407)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     x/lr1 [20]                      : (0.00208, 0.008013399176954733)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     x/lr2 [20]                      : (0.00208, 0.008013399176954733)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m   Others:\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     Name                        : exp\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     Run Path                    : nagasaki-soyorin/yolov5/eb4cdc7ef9174234ae189fce5bf9f820\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     comet_log_batch_metrics     : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     comet_log_confusion_matrix  : True\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     comet_log_per_class_metrics : True\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     comet_max_image_uploads     : 100\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     comet_mode                  : online\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     comet_model_name            : yolov5\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hasNestedParams             : True\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m   Parameters:\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     Lwf_enable          : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     Lwf_lambda          : 0.0001\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     Lwf_temperature     : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     SI_enable           : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     SI_lambda           : 10.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     SI_pt               : None\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     anchor_t            : 4.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     artifact_alias      : latest\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     batch_size          : 16\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     box                 : 0.05\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     bucket              : \n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     cache               : None\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     cls                 : 0.18125\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     cls_pw              : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     copy_paste          : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     cos_lr              : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     degrees             : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     device              : \n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     entity              : None\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     evolve              : None\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     evolve_population   : data/hyps\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     ewc_lambda          : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     ewc_pt              : None\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     exist_ok            : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     fl_gamma            : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     fliplr              : 0.5\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     flipud              : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     freeze              : [0]\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hsv_h               : 0.015\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hsv_s               : 0.7\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hsv_v               : 0.4\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|anchor_t        : 4.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|box             : 0.05\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|cls             : 0.5\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|cls_pw          : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|copy_paste      : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|degrees         : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|fl_gamma        : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|fliplr          : 0.5\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|flipud          : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|hsv_h           : 0.015\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|hsv_s           : 0.7\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|hsv_v           : 0.4\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|iou_t           : 0.2\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|lr0             : 0.01\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|lrf             : 0.01\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|mixup           : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|momentum        : 0.937\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|mosaic          : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|obj             : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|obj_pw          : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|perspective     : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|scale           : 0.5\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|shear           : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|translate       : 0.1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|warmup_bias_lr  : 0.1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|warmup_epochs   : 3.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|warmup_momentum : 0.8\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     hyp|weight_decay    : 0.0005\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     image_weights       : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     imgsz               : 640\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     iou_t               : 0.2\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     label_smoothing     : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     local_rank          : -1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     lr0                 : 0.01\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     lrf                 : 0.01\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     mixup               : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     momentum            : 0.937\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     mosaic              : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     multi_scale         : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     name                : exp\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     ndjson_console      : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     ndjson_file         : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     noautoanchor        : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     noplots             : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     nosave              : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     noval               : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     obj                 : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     obj_pw              : 1.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     optimizer           : SGD\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     patience            : 100\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     perspective         : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     project             : runs/train\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     quad                : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     rect                : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     resume              : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     resume_evolve       : None\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     save_dir            : runs/train/exp158\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     save_period         : -1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     scale               : 0.5\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     seed                : 0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     shear               : 0.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     single_cls          : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     sync_bn             : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     translate           : 0.1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     upload_dataset      : False\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     val_conf_threshold  : 0.001\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     val_iou_threshold   : 0.6\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     warmup_bias_lr      : 0.1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     warmup_epochs       : 3.0\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     warmup_momentum     : 0.8\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     weight_decay        : 0.0005\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     workers             : 8\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m   Uploads:\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     asset                        : 13 (1.95 MB)\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     conda-environment-definition : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     conda-info                   : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     conda-specification          : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     confusion-matrix             : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     environment details          : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     git metadata                 : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     images                       : 106\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     installed packages           : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     model graph                  : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m     os packages                  : 1\n",
      "\u001b[1;38;5;39mCOMET INFO:\u001b[0m \n"
     ]
    }
   ],
   "source": [
    "command = f\"\"\"\n",
    "env COMET_LOG_PER_CLASS_METRICS=true python train_Lwf.py \\\n",
    "--img 640 \\\n",
    "--bbox_interval 1 \\\n",
    "--cfg models/yolov5s_VisVOCKITTI.yaml \\\n",
    "--data data/VisDrone_incremental.yaml \\\n",
    "--epochs 10 \\\n",
    "--weights ./runs/train/increment_VOC_plain/weights/best.pt \\\n",
    "\"\"\"\n",
    "!{command}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f532b1b-c2ea-4d56-9428-2e586398df95",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
